﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Caching;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AJAX_learning.Chapter11
{
	public partial class p6 : System.Web.UI.Page
	{
		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad(e);
			
			var con = new SqlConnection(WebConfigurationManager.ConnectionStrings["Northwind"].ConnectionString);
			var cmd = new SqlCommand("SELECT EmployeeID, TitleOfCourtesy, FirstName, LastName FROM Northwind.dbo.Employees", con);
			var da = new SqlDataAdapter(cmd);
			var ds = new DataSet();

			da.Fill(ds, "Employee");
			var empDependency = new SqlCacheDependency(cmd);
			Cache.Insert("tbEmployees", ds.Tables["Employee"], empDependency);
			SqlDependency.Start(WebConfigurationManager.ConnectionStrings["Northwind"].ConnectionString);
		}
	}
}